
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2447. -- 消防站 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2447: 消防站</h2><span class=green>Time Limit: </span>2 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>8&nbsp;&nbsp;<span class=green>Solved: </span>8<br>[<a href='submitpage.php?id=2447'>Submit</a>][<a href='problemstatus.php?id=2447'>Status</a>][<a href='bbs.php?id=2447'>Discuss</a>]</center><h2>Description</h2><div class=content><div style="text-indent: 21pt">某个城市有N个区域，这些区域用1到N这N个正整数编号，并且它们之间通过N-1条道路相连，保证任意两个区域有路径相通。对于每个区域i,有一个正整数权值w(i)。记d(u,v)为区域u和区域v之间的距离，表示它们之间唯一的一条路径的边数。若u和v为同一个区域，则d(u,v)=0。</div>
<div style="text-indent: 21pt">现在要选择两个区域建立消防站，你的任务是找出这两个不同的区域x和y使得以下的表达式S(x，y)的值最小。</div>
<p><img alt="" src="/JudgeOnline/upload/201108/aaa.jpg" /></p></div><h2>Input</h2><div class=content><div class="Section0" style="layout-grid:  15.6pt none">
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">共<font face="Times New Roman">N+1</font><font face="宋体">行。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">第一行有一个正整数<font face="Times New Roman">N</font><font face="宋体">，表示区域的个数。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来有<font face="Times New Roman">N-1</font><font face="宋体">行，每行两个整数</font><font face="Times New Roman">u</font><font face="宋体">、</font><font face="Times New Roman">v</font><font face="宋体">，表述区域</font><font face="Times New Roman">u</font><font face="宋体">和区域</font><font face="Times New Roman">v</font><font face="宋体">之间有一条道路。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">最后一行有<font face="Times New Roman">N</font><font face="宋体">个正整数，第</font><font face="Times New Roman">i</font><font face="宋体">个正整数表示区域</font><font face="Times New Roman">i</font><font face="宋体">的权值</font><font face="Times New Roman">W(i)</font><font face="宋体">。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
</div>
<!--EndFragment--></div><h2>Output</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">包含一个正整数，为最小的<font face="Times New Roman">S(x,&nbsp;y)</font><font face="宋体">的值。&nbsp;</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>5<br />
<br />
<br />
1 2<br />
<br />
<br />
1 3<br />
<br />
<br />
3 4<br />
<br />
<br />
3 5<br />
<br />
<br />
5 7 6 5 4 <br />
<br />
<br />
<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>14<br />
<br />
<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p>【样例解释】</p><br />
<p><br /><br />
选取区域2和区域3。</p><br />
<p><br /><br />
【数据规模和约定】</p><br />
<p><br /><br />
用H表示距离区域1最远结点的距离，即d(1, u)的最大值。</p><br />
<p><br /><br />
对于30%的数据满足：2 &le; N &le; 300</p><br />
<p><br /><br />
余下70%的数据满足：2 &le; N &le; 50000、H &le; 70、W(i) &le; 100<br /><br />
</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=2011福建集训'>2011福建集训</a></p></div><center>[<a href='submitpage.php?id=2447'>Submit</a>][<a href='problemstatus.php?id=2447'>Status</a>][<a href='bbs.php?id=2447'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
